package com.dwxt.cdms.controller;

import com.dwxt.cdms.entity.Equipment;
import com.dwxt.cdms.vo.SelectEquipmentVo;
import com.dwxt.cdms.service.EquipmentService;
import com.dwxt.common.base.BaseResult;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 设备管理
 *
 * @author Kuang.JiaZhuo
 * @date 2020-09-04 17:44
 */
@RestController
@RequestMapping("/cdms/equipment")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class EquipmentController {

    private final EquipmentService equipmentService;

    /**
     * @方法名：createOrUpdateEquipment
     * @描述： 新增或修改设备档案
     * @作者： kjz
     * @日期： Created in 2020/9/4 17:53
     */
    @RequestMapping("/createOrUpdateEquipment")
    public BaseResult createOrUpdateEquipment(Equipment equipment) {
        return BaseResult.ok(equipmentService.createOrUpdateEquipment(equipment));
    }



    /**
     * @方法名：pageEquipmentList
     * @描述： 按条件查询设备列表(带分页)
     * @作者： kjz
     * @日期： Created in 2020/9/4 18:32
     */
    @RequestMapping("/pageEquipmentList")
    public BaseResult pageEquipmentList(SelectEquipmentVo selectVo) {
        PageInfo<Equipment> pageInfo = equipmentService.pageEquipmentList(selectVo);
        return  BaseResult.ok(pageInfo);
    }

    /**
     * @方法名：deleteDataByIds
     * @描述： 批量删除设备
     * @作者： kjz
     * @日期： Created in 2020/9/5 14:51
     */
    @RequestMapping("/deleteDataByIds")
    public BaseResult deleteDataByIds(String[] ids) {
        int result = equipmentService.deleteDataByIds(ids);
        return BaseResult.ok(result);
    }

    /**
     * @方法名：selectEquipmentById
     * @描述： 根据id查询设备详情
     * @作者： kjz
     * @日期： Created in 2020/9/5 15:16
     */
    @RequestMapping("/selectEquipmentById")
    public BaseResult selectEquipmentById(String id) {
        Equipment equipment = equipmentService.selectEquipmentById(id);
        return BaseResult.ok(equipment);
    }
}
